package solution;

import java.util.Scanner;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-20
 */
class Solution {
    //第一个不重复的字母
    public int firstUniqChar(String s) {
        int[] count = new int[255-97];
        for (int i = 0; i < s.length(); i++) {
            count[s.charAt(i) - 97]++;
        }
        for (int i = 0; i < s.length(); i++) {
            if (count[s.charAt(i) - 97] == 1) {
                return i;
            }
        }
        return -1;
    }
    // public static void main(String[] args) {
    //     Scanner scan = new Scanner(System.in);
    //     String s = scan.nextLine();
    //     int index = s.lastIndexOf(' ');
    //     System.out.println(s.length() - index- 1);
    // }

    //数最后一个单词的长度
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        String[] str = s.split(" ");
        System.out.println(str[str.length-1].length());
    }

    //判断回文字符串（只看字母和数字）
    public static boolean isEffective(char ch) {
        return Character.isLetterOrDigit(ch);
    }
    public static void main3(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        int left = -1;
        int right = s.length();
        boolean ret = true;
        while (left < right) {
            //右移到有效位置
            while (!isEffective(s.charAt(++left))) ;
            while (!isEffective(s.charAt(--right))) ;
            //左移到有效位置
            if (s.charAt(left) != s.charAt(right)) {
                ret = false;
                break;
            }
        }
        System.out.println(ret);
    }

    public static void main2(String[] args) {
        String s = ", , , ,        a, eaefa";
        String[] str = s.split(" ");
        System.out.println(str);
    }

    public static void main(String[] args) {
        String s = "AHBUFIE";
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch >= 'A' && ch <= 'Z') {
                ch += 32;
            }
            ret.append(ch);
        }
        s = ret.toString();
        System.out.println(s);
    }
}

